Moved db alterations to separate functions