improved random string function