Move code from #40 into tiles().