Added sorting
Removed te repeat in the Graph