update example code
replace error functions with return statements; function decleration updated