Added proper Error handling for runtime exceptions