re-implement history to be cleaner