added a bunch of write statements to try to debug