Generic sequence manipulation functions