Safer way to check array type