refactored graph reader