Added word reversal algorithm