Refactored inArray