I think you can get rid of this if statement. Just iterate over the buckets, if it's empty there is no work to do and that's fine.