bug fixed - infinite loop