Consider extracting this `if` into functions