more elegant way to update the environment