update w/ if instead of while