javascript fix for randomiser