Fixed the infinite looping.