wrote most of main, ready for a test