complete obj function (Xij)