convert 2-d problem into 1-d