Added error checking with websockets