Clock algorithm