Added Loop logic and shuffle logic