Working clock using nested for loops