Use string instead of a temporary array to improve performance