split up createBlock function into separate functions