[UPDATE] use idx instead of array copy.