comments added and variables renamed