Use existing functions like `string-trim', `thing-at-point' and remove unneeded code from the two functions