my understanding of this code needs improvement