optimized writeBucket