I see I forgot to initialize aidx and bidx.. what were the corner cases?