def isvalid_config(config, key, default, valid_list, logger=None):
    """Function that checks if a value for key exist in config and if it doesnt
    exist uses the default value, and see if the value/default exists in the valid_list

    Args:
        config (dict): config object
        key (str): key to used to get value from config
        default (str): default value to be assigned if not value exist for key
        valid_list (list): list of valid choices for key
        logger (logger.getlogger): log the error output. Defaults to None.

    Returns:
        value/False: returns the valid value or False
    """
    val = config.get(key, default)
    if val in valid_list:
        return val
    else:
        if logger is not None:
            logger.error(
                f"User input {key} = {val} is invalid!\n" f"Use values in: {valid_list}"
            )
        return False