Made the connection to redis db into a function