replace == None with is None
check instance type with isinstance