refactoring: add assertion instead of explicit null check