small refactoring and exception handling of DBhandler