refactored revert implementation