added error trap