the nested while is kind of working