code review...

Each of these "logics" needs to be extracted together with the rest of the related stuff above (e.g. the relevant predicate).