Refactor handler