refactor adjacent tile function