Added a bit of explanation to the code