added functional programming filter function