split out db calls and added filter()