external clock function