added reversal of row code