added code for gain variation studies