Fix a the bug that range should be expanded. Perfect dot product version.