Added comments and code clarity.