refactored serial io working