Added debug messages to find where my code breaks.