refactor callbackwrapper and added jsdocs