for replacing while loops