fixing a null pointer error