Fixed: ReferenceError: module is not defined

I've fixed the "ReferenceError: module is not defined" checking if the module has been defined before being used.