added error check
fixed