improved the createBlock method with a helper function to reduce # of lines.