rewrote the build method so it is a bit simpler