added code for filtering