Simplify and generalize not.related function