Refactor local_debug