Updated helper method, use generator instead to save memory when reading sequence