use more consistent gain function