handle nested while if