more refactor to pass around the database key