restructure + db access