Better function to convert array to string