Refactor emit helper