Added exception handler for easier debugging