used javascript magic rather than loops to clone array