Factorize fetch_timestamp() into its own function