fix and refactor halve