add error check in ex6