Refcator single line while loop