restructure filter to allow async i/o