Changed the allFlag variable, making it simpler