optimized some code.