fixed do/while loop, as per coding standards