Adding error handlings.