fixed problems with nullpointer