added err distribution function