Using interrupts instead of polling. Gpio change module is working properly.