added some annotation to make sense of the code