fixes a potential null pointer bug
resolves #436