Filter implementation added. Code restructured.