Added automatic while loop