fixing up serial code