fix for AttributeError: 'NoneType' object has no attribute 'user'