SIM 800C not getting respose every time

Hello ,
I have designed a sim800c module . It has sufficient current and connects to network every time . Also the call and sms work fine. but my problem is that it might not be getting the response every time so it just hangs.
I have used a while loop so that the next command is not send before the earlier response is received. I think it is getting stuck there.
I call multiple numbers and send sms to the same (this works fine). It exactly hangs when all the sms and calls are done after which I return to my homescreen to show signal strength .

Please suggest some solution. I don’t have any problem with the call and sms feature its just the response.
Thanks in advance

Problem is in your coding, You need to implement timeouts to wait for only a certain amount of time and retry.

We can retry only if the call or sms was not received . My problem is that the call gets connected but the while loops doesnt end. I am attaching my code please let me know if I am doing something wrong. Thank You

void GSM_Call(char *MobileNumber,int UART_PORT_NO){

char data[25] ;

GSM_Init(UART_PORT_NO);

char command[20]= "ATD+            ;\r";
int i;

//********************************************************************

for( i=4 ; i<16 ; i++)
{
	command[i]=*MobileNumber;   // Add mobile number to command
	MobileNumber++;
}
TX_string(command,UART_PORT_NO);
DELAY_MS(500);
while(Check_Response('O','K',UART_PORT_NO) != 1)
{

}

DELAY_MS(2000);

while(Check_Response('N','O',UART_PORT_NO) != 1){

}
LCD_COMMAND(0xCF);
SEND_STRING_TO_LCD(".");

}

void GSM_Send_Message(char *MobileNumber,char *data_byte,int UART_PORT_NO){
int i = 0;
int SMS_Flag = 0;
int SMS_BOX_Flag = 0;
char data[25] ;
char command[100]= “AT+CMGS=”+ “\r”;

//*****************************************************//
TX_string("AT+CMGF=1\r",UART_PORT_NO);  /////Turn to SMS sending mode
DELAY_MS(500);
while(Check_Response('O','K',UART_PORT_NO) != 1)
{

//
}

for( i=10 ; i<22 ; i++)
{
	command[i]=*MobileNumber;   // Add mobile number to command
	MobileNumber++;
}
TX_string(command,UART_PORT_NO);
DELAY_MS(500);

while(SMS_BOX_Flag != 1){

    strcpy(data,RX_String(UART_PORT_NO));

    for(i=0;i<50;i++){

    	if(data[i] == '>'){
    		SMS_BOX_Flag = 1;
    	}

    }

	DELAY_MS(500);

}

TX_string(data_byte,UART_PORT_NO);   ////Transmitting message
TX_CHAR(0x1a,UART_PORT_NO);   //ASCII for ctrl+z
DELAY_MS(1000);

while(SMS_Flag != 1){

    strcpy(data,RX_String(UART_PORT_NO));

    for(i=0;i<50;i++){

    	if(data[i] == '+' && data[i+1] == 'C' && data[i+2] == 'M' && data[i+3] == 'G' && data[i+4] == 'S'){
    		SMS_Flag = 1;
    	}

    }

	DELAY_MS(500);

}


DELAY_MS(1000);
while(Check_Response('O','K',UART_PORT_NO) != 1)
{

}

}