I feel this function is too large. May we break the down?
Like:
1. the creation of each criteria functions can be a function,
2. the switch case can be another one.