added a local variable to avoid traversing the tile objects 6 times !