adapt the filtering routine to handle different a/b lengths