added a null pointer check to module loading