Placed reset variables inside loop.