Refactor dbfilename into a helper method