Suppose I have a gas expanding. The gas is an isolated system and has an internal pressure. Outside there is another pressure. If I then want to find how much energy the gas loses, do I then see it as the internal pressure of the gas doing a positive work on the atmosphere or the atmospheres pressure doing a negative work the gas? Because the two pressures are different and I don't see which pressure is better using - both procedures make sense to me - which one is wrong and why?