added error and end functionality to redis connection