implemeted successfully till mode-filter(Section 3.5) but used loops