method extract and refactor