added more explanation and formatted code