Update function implemented in environment class. Old name of the environment should be passed if the name has changed.