started work on #23, improved IO