Created helper string truncation function