move build function inside of functions and update Makefile