Flexible and robust procedure for subgroup inference