correction of organizational discrepancies

and new variable for cursor as to simplify if statements.