Fixed loop issue