fixed midnight bug and debug output