changed function to g