Updated exception handling to use StandardError