Optimized some code