added random arr in kernel
removed some unused variables
Update Z now works, using double