updating db and adding reference