Adding guards against null pointer's (for if without else)