correction to beta reduction code