fixbug: crash when begin is nil.