strip characters correctly