use typedef now that it's in the class
fixed bugs, implemented G