Fix bug in gains