change str to basestring to handle unicode