Optimized get_password function

Now uses password.length instead of counter variable.