refactor half