reworked algo1 for pointers.