optimized some code