updated loops to use hardware timing