put database stuff where it belongs