change the read and publish code to fix the delay in the serial communication