I assume it's not possible to remove the duplication of this code with the same code in the other conditional by putting it after the if-else?