finished serial code