How cavities are formed