add requireAll option plus some random refactorings
add requireAll option