hopefully fixed null pointer bug