Fix for nullpointer exception