Use return instead of echo for better functionality
Adjust script to use return instead of echo. Create array and loop through function.