made mid a local variable