refactor helper method