working LP optimization...finally