Move DB related methods to model