some code optimizations