smplified filter-related codes and fixed some bugs