added gain parameter and made suggested changes to documentation