Changed syntax and added cursors.