refactoring code using partials