Check whether history is defined before using it