improve input method and add comments