use str instead of basestring if python3
use .format instead of % for string formatting