almost done with graphics function