optimized some functions