not a fan of jumping scope here. Can we pass "project" into this function, since it gets called in four possible code paths later on.