Add reverse function using queue