bug fix; add log_state