fix bugs when accessing tiles out of range