Added loop conditions