some speed optimizations