fixed filter function, still have to test