Add while and if statements; try to debug advance() function