updated code with graphs
updated code with graph