Could you please think about how to remove this duplicated code (see below, else branch)