Refactor some code to avoid duplication