changed cursor() from recursion to while loop

this addresses issue #283

ps: happy for discussion on this...