correction, changed if to do-while