Fixed revert damage and refactor code