Sunday work, plotting works but main function has some error in it