Fixed bug in do/while loop