A few changes to account for different array lengths