remove: remove err_handler() and simplify some check code