Fix mongo error when refresh page