refactor and fix password auto-update system