Moved filter functionality into separate file