Refactor to remove unnecessary code