fixed cursor null pointer error