rewrited search for log(n), added constants