Tested and fixed the infinite loop system