added dot reduction code