moved logic to context
refactor