Added my code and explanatory comments