use seq_along(x) instead of 1:length(x), seq_len() instead of 1:foo