improve database code (get ready for content provider)