handle missing parameter well, encapsulate db access