a cleaner and more complete way to avoid the 'NoneType' error