Fixed loop issue and timeout issue