tidyied up database