Move array manipulation logic to external service