Add a try catch structure to prevent crashes