Null check and removed redundancies