cleaned up sample and timing code