while loop had unneccessary check