prevent taking log(0)