Refactoring and null checking