code speed up for doubles