Refactor head processing