I have not tested the idea.

Instead of writing each IF-THEN test to the port, writing to a variable and at the end that variable to the port will be faster?

Ioannis