Changed error handling from Exception to Error