Added simple error/exception handle and logging