Changed str to unicode to support non-ASCII characters