Code to deal with midnight crossover