A molecular mechanism that allows memories to form