added invalidate and cleaned up key created a bit