fixed x sorting issue in for loops lines 50 -60-ish