moved timing code around