gainchart code modification