typo's in variable names. Replaced handle in vars with result where necessary