Refactor, remove duplication.