add error handling. #11
pass the test of vignette. #11