Fix existing code by following the early exit rule