refactored parseGivenCode function and renamed variables
user can press up arrow or down arrow to go through past entries