fixing typos and 'then the' constructs