fix reference bugs