refactored callback codes