fix a null pointer error in controller