Bug in generate password code