some minor changes
add user-defined pairwise cost function