Added error checks