add state time code to PTTS function