changed while loop to accomodate "all" keyword