adds immediately invoked function to query database every 5 seconds