Refined code

More comments so novices can understand