Move generate password function to be instance method