adding more nullpointer checks