serial code with major changes