Exit via return instead of breaking out of the loop