android studio issue in signing in to an application : I have an issue regarding signing in..!

    

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

    package com.example.myapplication;

    import android.app.ProgressDialog;
    import android.content.Intent;
    import android.support.annotation.NonNull;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.text.TextUtils;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;

    import com.google.android.gms.tasks.OnCompleteListener;
    import com.google.android.gms.tasks.Task;
    import com.google.firebase.auth.FirebaseAuth;
    import com.google.firebase.database.DataSnapshot;
    import com.google.firebase.database.DatabaseError;
    import com.google.firebase.database.DatabaseReference;
    import com.google.firebase.database.FirebaseDatabase;
    import com.google.firebase.database.ValueEventListener;

    import java.util.HashMap;

    public class RegisterActivity extends AppCompatActivity

       {
           private Button CreateAccountButton;
           private EditText InputName, InputPhoneNumber, InputPassword;
           private ProgressDialog loadingBar;
           FirebaseAuth mAuth;

        @Override
        protected void onCreate(Bundle savedInstanceState)
                {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_register);

            CreateAccountButton = (Button) findViewById(R.id.main_register_btn);
            InputName = (EditText) findViewById(R.id.register_username_input);
            InputPassword = (EditText) findViewById(R.id.register_password_input);
            InputPhoneNumber = (EditText) findViewById(R.id.register_phone_number_input);
            loadingBar = new ProgressDialog(this);
            mAuth = FirebaseAuth.getInstance();
            

            CreateAccountButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v)
                {
                    CreateAccount();
                    

                }
            });

        }

           private void CreateAccount()
           {
               String name = InputName.getText().toString();
               String phone = InputPhoneNumber.getText().toString();
               String password = InputPassword.getText().toString();
               if (TextUtils.isEmpty(name))
               {
                   Toast.makeText(this, "please enter your name", Toast.LENGTH_SHORT).show();
               }
              else if (TextUtils.isEmpty(phone))
               {
                   Toast.makeText(this, "please enter your phone number", Toast.LENGTH_SHORT).show();
               }
              else if (TextUtils.isEmpty(password))
               {
                   Toast.makeText(this, "please enter your password", Toast.LENGTH_SHORT).show();
               }
               else
               {
                   loadingBar.setTitle("Create Account");
                   loadingBar.setMessage("Please wait, While we are checking the credentials");
                   loadingBar.setCanceledOnTouchOutside(false);
                   loadingBar.show();

                   validatephonenumber(name, phone, password);

               }


           }

           private void validatephonenumber(final String name, final String phone, final String password)
           {
               final DatabaseReference RootRef;
               RootRef = FirebaseDatabase.getInstance().getReference();

               RootRef.addListenerForSingleValueEvent(new ValueEventListener()
                {
                   @Override
                   public void onDataChange(@NonNull DataSnapshot dataSnapshot)
                   {
                      if(dataSnapshot.child("Users").child(phone).exists())
                      { Toast.makeText(RegisterActivity.this, "this" +phone+ "alredy exists", Toast.LENGTH_SHORT).show();
                          loadingBar.dismiss();
                          Toast.makeText(RegisterActivity.this, "Please try using another phone number", Toast.LENGTH_SHORT).show();

                          Intent intent= new Intent(RegisterActivity.this, MainActivity.class);
                          startActivity(intent);

                      }
                      else
                      {

                          HashMap<String, Object> userdataMap = new HashMap<>();
                          userdataMap.put("Phone", phone);
                          userdataMap.put("password", password);
                          userdataMap.put("name", name);

                          RootRef.child("User").child(phone).updateChildren(userdataMap)
                                  .addOnCompleteListener(new OnCompleteListener<Void>() {
                                      @Override
                                      public void onComplete(@NonNull Task<Void> task)
                                      {
                                          if (task.isSuccessful())
                                          {
                                              Toast.makeText(RegisterActivity.this, "Congratulations your account has been created ", Toast.LENGTH_SHORT).show();
                                              loadingBar.dismiss();

                                              Intent intent= new Intent(RegisterActivity.this, loginActivity.class);
                                              startActivity(intent);
                                          }

                                          else
                                          {
                                              loadingBar.dismiss();
                                              Toast.makeText(RegisterActivity.this, "Network Error: Please try again", Toast.LENGTH_SHORT).show();
                                          }



                                      }
                                  });
                      }

                   }

                   @Override
                   public void onCancelled(@NonNull DatabaseError databaseError) {

                   }
               });

           }
       }


<!-- end snippet -->

  
when I'm using this code and signing in with a phone number for second it should actually prompt "this number already exists" but its working and upon siging in with same number again all the older names and passwords are being replpaced by new ones....how can i solve this issue???