bug fix loop