Cleaning up filtering of arrays