Refactored array to string conversion