added filter; some refactoring