implementing clock() / edge() pattern