Added exception catching for debugging