refactoring double-callback protection
further refactoring of double-callback protection