Refactor callback hook