smoother filtering and error checking