realm detection logic reversed