** Added code to handle up/down keys correctly for CLI **