fixed password logic and consolidated it