Refactored the code and added support for FilterType