modified PRU code so that it runs when needed