added undefined to factory function