added ability to read input of variable size; still need to fix some bugs