added do nothing if value==NULL
quick mod
modified 1:length to seq_len to avoid i=1 when len=0