Could you rewrite this adding a early return?

I think that the readibility will be significantly improved due the reduction in the indentations and `elseif`