add detect to commit_leader to prevent nil error