added code to add ability to send serial command before and after each layer