Generic sequence function