Pulling out common logic in tile directive to local named functions