Refactor merged code