fix loop issue