first compilable version of the build_blocks function