add reverse words algorithm