added a new state variable called ambient and changed all the dependent functions