Yes, that's the order that makes sense!
Are you creating password before using it and putting the if part before the else part?
password
if
else