Add Objective function 2

fix few bugs