fix bug on rebuilds