move the cursor and setting memory