refactored prefiltering into the library