In tis function I think we are abusing from the early return pattern. Could we have a more structured version of it?