changed logic for all buckets
changed logic for all buckets -working