Refactors indefinite loop to one line