consolidating debug code a bit-- hopefully it works