add more information to the error message when required config data is missing
replace duplicate user-from-prefix code with a function