implementing algorithms