slight modification and commention of code