Adjusted build function to work properly