fixing bug in profile code