little rework of environment implementation