added a way to end loops