def age_check(df):
    """
    Checks age is within permitted bounds
    If age is missing or outside bounds,
    replaces age with median age

    Parameters
    ----------
    df : main dataset

    Returns
    -------
    df : main dataset
        adds age_admit column

    """
    df.loc[df['age_admit'] > 110, 'age_admit'] = None
    df.loc[df['age_admit'] < 16, 'age_admit'] = None
    med_age = df['age_admit'].median()
    df['age_admit'] = df['age_admit'].fillna(med_age)
    return df