adding a new version of rev string, based on Sam's solution.