updated def input and encoding method