preparing some algorithms