Removing infinite loop