fixed nullpointer on exit