kwise_reverse function created