Added error handlings