comments added, code cleanup