Gains were not being computed correctly