Added Ternary operator to append text to the history.