another optimization for threading