Refactor callbacks