fixed nullpointer exceptions