added scripts; made readSerialData a function