reformatted how errors work in functions