split db access into separate module
add memory abstraction