Refactors to a better flow of logic