optimizations for speed