fixing some null pointer exceptions