globals are bad, fixed not passing env to calc