Use the goto of functional programming instead of mutating/loop