corrected the err fun