Added randomized testing to test updateG