using isinstance rather than type compare