implemented memory for learning states