When the timer fails, the entire function should probably return instead of looping again in the outer for-loop.