Move DB related thingy into its own methods