add some optimizations