adding prev function