modified checkInactive because for loop init error