Updated the code to use my SPI function