refactor before filter