Fix bugs filter and refactor filter