refactor by sending context variables