Refactor codes in bucket-transform-handler