Added try catch in main loop to prevent errors crashing the server