Fix for array length error