added optimal solution