Refactoring the way criteria is built to reduce unecessary duplication