Added second algorithm