Add validation and improve string concatenation