refactor logic, incorporate .done evaluation into while()