[TASK] Moves db access to new function