That link doesnt show any code post the whole thing then I might be able to help. There is obviously a dist variable that needs to be calced for that code to work.