Moved undefined array initialization check up so that it captures both sides of the if statement