remove duplicated code for smart concatenation