removed unneeded while loop