fixing problem with nullpointerexception