cursor handling cleaned up a bit