optimized some bugs