Added end tile determination