refactor anonymous function in .every function into a separate variable, allElementsTrue