got nested while loops to work