addresses #9 and uses #10 - renames variables and properly handles exception