refactor common behavior