Made gain a variable listed at the top