improve error & log handling