added error validation