fixed up slight history bug when history is full
added documentation