optimizations - save 60% cpu time