alghorithm implemented