added cursor.advance() example, and tidied up the code a bit