add context as ways argument, and define refresh_context