Implementation of useful algorithms