Added filter function. Not much of effect on the small test set...