Convert split and filter to a function. Avoid Code Duplication!!!