Modified calculator code from ScriptEdCurriculum