Fixed looping issue