more inline comments added, indentation corrected