Add dir argument to filter function

fixes #11
closes #18