modified to work with multiple Tiled tile sets properly

I was experimenting with multiple tile sets in tiled and noticed that it doesnt work properly, i think this fixes it