Added epsilon to avoid log of negative numbers