Modified code to update correctly when password is present