handy functions to deal with cursors