Fixed undefined realm error