refactored filter and handler