fixed log 0 problem (0 replaced by 10* machine epsilon)