simplifying serial read code