added proper sequence length check
added createSequenceFunc for more modularity