added FreeCursor call
Better architecture