Bug fixed: dead loop