Hi there all JASS guru's I have a question, will this trigger work as I want?
And is there anything I can improve?
(1000.00 is the speed of the projectile on the spell)
EDIT: Oh sry posted in the wrong forum :/ had them both opened and didnt notice which one I posted in, can some mod move it?

JASS:
function Icebolt takes unit caster, unit target, real duration, real slowprecent returns nothing
local real x1 = GetUnitX(caster)
local real x2 = GetUnitX(target)
local real y1 = GetUnitY(caster)
local real y2 = GetUnitY(target)
local real dist = SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
call TriggerSleepAction( ( dist / 1000.00 ) )
call SetUnitMoveSpeed( target, slowprecent )
call TriggerSleepAction(duration)
call SetUnitMoveSpeed( target, GetUnitDefaultMoveSpeed(target) )
set caster = null
set target = null
endfunction