refactor/fix attribution fn