Refactor comparing each element to the unique_array instead of itself so that iteration doesn't get messed up by deleting