Fixed unfinished parts of loop.