handle while loops