adds some code to manage I/O and main method