Fix usage example for the when function and write more descriptive comment