fixed: crash and infinite loop