optimized core (first version)