removing unnecessary entries from history