simplified the logic and predicates