Refactor age buckets function