adding comments and renaming for better understanding