fixing bug from using old code