working loop and index