refactor to put common stuff in utilities
put build fucntion into utilities
further refactor