Removed commented code and loop limiting mechanism.