Adding a few null checks