fix up cursor creation, but added a malloc. Need to revisit later