Move bucket creation code to own method