fix typo and crash on zero length sequences