first approximation to algorithm