Fixed code so that there is a distinct loop functionality for boh the normal and _d versions.