'NoneType' object has no attribute 'dat'