simple implementations for various algorithms