backend: env uses pattern matching to mimic recursion