add some error handlings