Move env out of view into controller