switched to a while statement