optimized code; more rosalind