Refactored callback setup