minimize error with boundaries