Worked further on filtering function