revise input functions

left:
  revise algorithm