adding reversing function