changed some lines for graph smoothness