added ability to calculate gains