Improved wordwrap function