fixed the bug with undefined arrays