copied his code for extend env recur and the global environment initial