modified evalScript to be a case expression, to alleviate repeated variable bindings.