Rewrite graph code, ps: its still shit