Updated the server with a try catch block for substring