Formation of five-coordinate calcium and magnesium complexes