Added comment explaining how it works at the end