added conditional check on filter