Added Null-check
Refactor