fixed looping error