added new reverse algorithm