finished timing code (untested - not added to db)