Refactor
Refactor
Update exception type
Fix code according to code analysis