Make sure to close cursor