my function works only in one direction. Either she only goes once or only once. depending on whether I switch on or off in the function. I can not find the mistake. in the debug is to see that from the function only one off comes, although the switch on outputs.