finish the function of reading the input