catch errors in calculating values