Add a few checks to prevent an error when user is not logged in