Collapsed loop
Moved outer short range loop to cpp