Refactor code to allow for user input