Refactor value filtering