added callbacks patch
refactoring