fixed up arrow key and down arrow key bug of not showing empty string in
input text field and some refactoring