added 'total' to the result json + added jsdoc