refactoring gpio pulses