rewrote reverse program with vectors