Make sure you don't end up in an infinite loop at the end