fixing null pointer error