Added error handing