improve addObjective implementation