updated error checking
fix wrong variable name