exception handling
minor refactoring