Added new code for tacking function gain