Modified the getTileAt function