fixing exit null pointer bug