softmax refactoring