fixed some null pointer error