LPS-51602

This is an update for [LPS-51602](https://issues.liferay.com/browse/LPS-51602).<br><br>This fix simply makes the logic functional.  I'll include my optimizations as poart of LPS-50466