Trying to impelment basic serial functions and error handling