Use isinstace basestring instead of type

It is the recommended way of checking if a variable is a string.