Removed inf while loop