Fix contextm middleware issue