get rid of while loops