Added comments and tested.