refactoring to methods