Optimized some functions