Functional programming challenge using filter method