Fix bug in _commit function