errors functions and plots done