updated SPI logic