some refactoring
exception handled