fixing critical bug from last PR