moved common timing code to state handler