remove infinite loop between two functions and make them return to main after finishing up the task