refactoring callbacks