made some minor changes, got rid of cursor, added some print statements