Assign buildDir at top of function