better sequence processing logic