Solution to RSM infinite loop issue by ordering results from data store