Divide serial code into its own class