a few optimizations