优化逻辑，修复bug