filter_execs to an independent function