add more error handlings