improved filehandling for mother