added try catch for server communication