calculateG added