improvements, now uses float64 for num