make graph smaller and clean up code