Refactor to remove redundancy