Edited algo to act as intended

Refs #7860