Now, Thats nice and easy. The only thing I would change is not having a variable for the state of the output pin but reading the output state.