added tracking of previous images