Functional rewrite of build()