slight refactor in array filter