reorganized user graph code