Fixed bug in how code was assuming data would be ordered