Made testing for errors more explicit. Added and filter.