combine comparison code