added some database code; not quite working yet