Change method from using break to 'while'