Added loop functionality.