refactor callback