refactor back-propagate