Some little code improvement regarding the exception and little refactoring
refactor