Fixed looping error