Refactor code to DRY search filter UI