tail functionality done using string builder