Made the gph function better