Refactoring to have smaller methods