had continue in the wrong place, added a bool to check if array sorting should go on