algorithm changes to allow >10 tiles wide
advance version