gain formula fix