Fix bug with complex criteria