use defined function instead of duplicate code

You already have concat function and I think that you could use it.