contains a lot of blank lines. That makes it appear that you are using the Serial Monitor to send data, and that the Serial Monitor is configured to add carriage return and line feed to the string being sent.
The master send "on," "off," like the code in the first post, and when i checked the serial monitor i saw those spaces too. I did not had those spaces when i used the example.
So, what you should be doing is looking for the String to contain "on" or "off", rather than for the String to BE "on" or "off".
I was thinking the same thing, will check on how to do this.