refactoring by breaking down into small methods