using logs to deal with tiny numbers.