created length and reverse functions