Refactoring jsdoc and the delegate function