redocument, fixed while loop