refactor to not pass context as arg to avoid circular references