Fixed algorithm for concatenating strings