Refactored code and added properties to graph