extracted helper methods for Database class.