make sequence handling generic