Refactored array comparison