moved timed capture functions inside main on loop