moved database stuff into it's own files