def get_molecules(topology):
    """Group atoms into molecules."""
    if 'atoms' not in topology:
        return None
    molecules = {}
    for atom in topology['atoms']:
        idx, mol_id, atom_type, charge = atom[0], atom[1], atom[2], atom[3]
        if mol_id not in molecules:
            molecules[mol_id] = {'atoms': [], 'types': [], 'charge': []}
        molecules[mol_id]['atoms'].append(idx)
        molecules[mol_id]['types'].append(atom_type)
        molecules[mol_id]['charge'].append(charge)
    return molecules