added soem more error handling with the code