Expanded on the implementation with comments and more explicit message calls.