enhanced gain algorithm