Fixed bugs in array extraction