Added some checking around the realm checks