just updating
adding final code with comments