added error checing