fixing a nilpointer problem