refactored code to enable input box to work