changed the begin loop to a while loop