finished cap[][] and add cost[][]