Added a try catch and fixed an error message